package ro.utcn.oop.mandelbrot.rmi.server;

/**
 * Implementation of the Mandelbrot service.
 * 
 * @author coni
 * 
 */
//clasa care implementeaza interfata
//metoda calculeaza setul Mandelbrot
public class MandelbrotService implements IMandelbrotService {

	public int calculate(double x0, double y0, int maxIterationNumber) {

		double x = 0;
		double y = 0;
		int numberIteration = 0;

		while (x * x + y * y < 2 * 2 && numberIteration < maxIterationNumber) {
			double xtemp = x * x - y * y + x0;
			y = 2 * x * y + y0;
			x = xtemp;
			numberIteration++;
		}
		return numberIteration;
	}
}
